﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MRSite.Cache.Generic
{
    public interface IGenericCache<TKey, TValue> : IDisposable
    {
        ICache InternalCache { get; }

        TValue Get(TKey key, Func<TKey, TValue> func);

        Task<TValue> GetAsync(TKey key, Func<TKey, Task<TValue>> func);

        TValue GetOrDefault(TKey key);

        Task<TValue> GetOrDefaultAsync(TKey key);

        void Set(TKey key, TValue value, TimeSpan? slidingExpireTime = null);

        Task SetAsync(TKey key, TValue value, TimeSpan? slidingExpireTime = null);

        void Clear();

        Task ClearAsync();

        void Remove(TKey key);

        Task RemoveAsync(TKey key);

        string Name { get; }

        TimeSpan SlidingExpireTime { get; set; }
    }
}
